import request from "../../api/request";
const market = "market";

// 组织机构获取
export function getOrgTree() {
    return request({
      url: "property/station/getOrgTreeByPerm",
      method: "get",
      // data: data || {}
    });
  }

  // 新增数据
export function save(data) {
    return request({
      url: market + "/stake/save",
      method: "post",
      data: data || {}
    });
  }

  //修改数据
  export function update(data) {
    return request({
      url: market + "/stake/update",
      method: "post",
      data: data || {}
    });
  }

   // 分页查询数据
export function listStakeByPage(data) {
    return request({
      url: market + "/stake/listStakeByPage",
      method: "post",
      data: data || {}
    });
  }

  // 删除
export function remove(params) {
    return request({
      url: market + "/stake/remove",
      method: "delete",
      data: params
    });
  }

  export function formatDateTimes(data) {
    if (data == null) {
      return "";
    }
    let dt = new Date(data);
    return (
      dt.getFullYear() +
      "-" +
      (dt.getMonth() + 1 < 10 ? "0" + (dt.getMonth() + 1) : dt.getMonth() + 1) +
      "-" +
      (dt.getDate() < 10 ? "0" + dt.getDate() : dt.getDate())
    );
  }

  // 时间格式化
export function formatDateTime(data) {
    if (data == null) {
      return "";
    }
    let dt = new Date(data);
    return (
      dt.getFullYear() +
      "-" +
      (dt.getMonth() + 1 < 10 ? "0" + (dt.getMonth() + 1) : dt.getMonth() + 1) +
      "-" +
      (dt.getDate() < 10 ? "0" + dt.getDate() : dt.getDate()) +
      " " +
      (dt.getHours() < 10 ? "0" + dt.getHours() : dt.getHours()) +
      ":" +
      (dt.getMinutes() < 10 ? "0" + dt.getMinutes() : dt.getMinutes())  +
      ":" +
      (dt.getSeconds() < 10 ? "0" + dt.getSeconds() : dt.getSeconds())
    );
  }